<script setup>
import { ref } from 'vue'
import * as echarts from 'echarts'
const optionData = {
  animation: true,
  tooltip: {
    trigger: 'axis',
    borderColor: '#0F2638',
    backgroundColor: '#0F2638DB',
    textStyle: {
      color: '#fff',
      fontSize: 14,
      marginLeft: '-20px'
    }
  },
  grid: {
    left: '2%',
    right: '3%',
    bottom: '2%',
    top: '20%',
    containLabel: true
  },
  legend: {
    data: ['风向', '风速'],
    textStyle: {
      fontSize: 10,
      color: 'rgb(167,177,187)'
    }
  },
  xAxis: [
    {
      type: 'category',
      data: ['14:20', '14:30', '14:40', '14:50', '14:60'],
      axisLabel: {
        textStyle: {
          color: 'rgba(255,255,255,.7)'
        }
      },
      axisLine: {
        show: true,
        lineStyle: {
          color: 'rgba(255, 255, 255, 0.2)'
        }
      },
      axisTick: {
        show: false
      }
    }
  ],
  yAxis: [
    {
      type: 'value',
      name: '单位：°',
      splitNumber: 3,
      // max: 400,
      nameTextStyle: {
        padding: [0, 10, 0, 0],
        color: 'rgba(255,255,255,.7)'
      },
      axisLabel: {
        textStyle: {
          color: 'rgba(255,255,255,.7)'
        },
        formatter: '{value}'
      },
      axisLine: {
        show: false
      },
      splitLine: {
        show: true,
        lineStyle: {
          type: 'dashed',
          color: 'rgba(255, 255, 255, 0.2)'
        }
      }, //设置网格
      axisTick: {
        show: false
      }
    },
    {
      type: 'value',
      name: '单位：m/s',
      // max: 40,
      splitNumber: 3,
      nameTextStyle: {
        padding: [0, 0, 0, 10],
        color: 'rgba(255,255,255,.7)'
      },
      axisLabel: {
        textStyle: {
          color: 'rgba(255,255,255,.7)'
        },
        formatter: '{value}'
      },
      axisLine: {
        show: false
      },
      splitLine: {
        show: false,
        lineStyle: {
          type: 'dashed',
          color: 'rgba(255, 255, 255, 0.2)'
        }
      }, //设置网格
      axisTick: {
        show: false
      }
    }
  ],
  series: [
    {
      animation: {
        // 对该系列的特定设置
        duration: 2000, // 动画持续时间，单位毫秒
        easing: 'bounceOut' // 动画缓动效果
      },
      name: '风向',
      type: 'line',
      showSymbol: false,
      smooth: true,
      symbolSize: 8,
      yAxisIndex: 0,
      lineStyle: {
        color: '#3CE4E8'
      },
      itemStyle: {
        // 设置symbol的颜色
        normal: {
          color: '#3CE4E8'
        }
      },
      areaStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: 'rgba(60, 228, 232, 0.5)'
          },
          {
            offset: 1,
            color: 'rgba(60, 228, 232, 0)'
          }
        ])
      },
      data: [120, 230, 380, 280, 180]
    },
    {
      name: '风速',
      type: 'line',
      yAxisIndex: 1,
      smooth: true,
      showSymbol: false,
      symbolSize: 8,
      lineStyle: {
        color: '#FFF37C'
      },
      itemStyle: {
        // 设置symbol的颜色
        normal: {
          color: '#FFF37C'
        }
      },
      areaStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: 'rgba(255, 243, 124, 0.5)'
          },
          {
            offset: 1,
            color: 'rgba(255, 243, 124, 0)'
          }
        ])
      },
      data: [12, 22, 18, 24, 12]
    }
  ]
}
const option = ref(optionData)
</script>

<template>
  <div class="card">
    <CommonTitle title="气象变化趋势" />
    <div class="chart">
      <Charts :option="option" />
    </div>
    <div class="flytime">
      <p>
        <span>气象设备总数</span>
        <span>/个</span>
      </p>
      <p><NumberAnimate :count="66"></NumberAnimate></p>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.card {
  margin-top: 15px;
  .chart {
    width: 95%;
    height: 180px;
  }
  .flytime {
    width: 100%;
    height: 43px;
    background: url('@img/overview/fly_servertime_bg.png');
    background-size: 100% 100%;
    display: flex;
    align-items: center;
    margin: 0 10px;

    p:first-child {
      flex: 1;
      display: flex;
      flex-direction: column;
      padding: 5px 0 5px 30px;
      span:last-child {
        color: #2f9cff;
      }
    }

    p:last-child {
      flex: 1;
      text-align: center;
    }
    &:deep(.countup-wrap CountUp) {
      span {
        font-family: DINAlternate;
        font-size: 28px;
        line-height: 28px;
        color: #ffffff;
        letter-spacing: 5px;
        background: linear-gradient(to bottom, #ffffff 0%, #00d5ff 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }
    }
  }
}
</style>
